* Desaster support to explain violence Hybrid model for 2000-2015

xtset code year
*drop those years for which no sufficient data are available
keep if year==1990 | year ==1995 | year ==2000 | year==2005| year==2010| year ==2015
*interpolation of important variables for which large amounts of missing values exist 
by code: ipolate Indigenous_Pop_Share year, gen(Indig_Share_Ipol) epolate
by code: ipolate Share_Head_of_HH_Female year, gen(Share_Female_HH_ipol) epolate
by code: ipolate Household_Size year, gen( Household_Size_Ipol ) epolate
by code: ipolate HDI_Services year, gen( HDI_Services_Ipol ) epolate
*Generate dummy variables for years and states
tabulate year, gen(year)
rename year1 y1990
rename year2 y1995
rename year3 y2000
rename year4 y2005
rename year5 y2010
rename year6 y2015
tabulate Estado_ID, gen(Estado)
xtset code year

* Binary part
xtlogit participation_hom mn_Spending_Cap_Real_Munic dev_Spending_Cap_Real_Munic   mn_Own_Revenue_Share dev_Own_Revenue_Share Group_cicl_des_em_dummy Group_sis_volc_des_em_dummy HDI_Services_Ipol Share_Female_HH_ipol Household_Size_Ipol Population_Density Population_15_29_Males  Males_Per_100_Females Indig_Share_Ipol Population Munic_Size_Categ Laakso_Tag_Ind Dummy_Border_PCoast y2000-y2015 Estado1-Estado32, re or

*Results and important additional parameters are stored in an excel file

putexcel set "Alt_mec_dis_panel0015.xlsx", sheet("Logit_0015") modify
putexcel I3=("Number of obs")
putexcel J3=(e(N))
putexcel I4=("Number of groups")
putexcel J4=(e(N_g))
putexcel I5=(" Wald_Chi2")
putexcel J5=(e(chi2))
matrix a = r(table)'
matrix a = a[., 1..6]
putexcel A2=matrix(a)

* Continuous part
xtreg Homicides_All_Cap_Pos_Log mn_Spending_Cap_Real_Munic dev_Spending_Cap_Real_Munic   mn_Own_Revenue_Share dev_Own_Revenue_Share Group_cicl_des_em_dummy Group_sis_volc_des_em_dummy HDI_Services_Ipol Share_Female_HH_ipol Household_Size_Ipol Population_Density Population_15_29_Males  Males_Per_100_Females Indig_Share_Ipol Population Munic_Size_Categ Laakso_Tag_Ind Dummy_Border_PCoast y2000-y2015 Estado1-Estado32, re robust

*Results and important additional parameters are stored in an excel file

putexcel set "Alt_mec_dis_panel0015.xlsx", sheet("Linear_0015") modify
putexcel I3=("Number of obs")
putexcel J3=(e(N))
putexcel I4=("Number of groups")
putexcel J4=(e(N_g))
putexcel I5=("Wald_Chi2")
putexcel J5=(e(chi2))
putexcel I6=("R2")
putexcel J6= (e(r2_o))
matrix a = r(table)'
matrix a = a[., 1..6]
putexcel A2=matrix(a)
